class MyStack:

    def __init__(self):
        self.queue_1=[]
        self.queue_2=[]
        self.topElem=None

    def push(self, x: int) -> None:
        self.queue_1.append(x)
        self.topElem=x
    def pop(self) -> int:
        if not self.empty():
            if len(self.queue_1)>0:
                while len(self.queue_1)>0:
                    if len(self.queue_1)>=2:
                        elem=self.queue_1.pop(0)
                        self.queue_2.append(elem)
                        if len(self.queue_1)==1:
                            self.topElem=elem
                    if len(self.queue_1)==1:
                        return self.queue_1.pop(0)
            else:
                while len(self.queue_2)>0:
                    if len(self.queue_2)>=2:
                        elem=self.queue_2.pop(0)
                        self.queue_1.append(elem)
                        if len(self.queue_2)==1:
                            self.topElem=elem
                    if len(self.queue_2)==1:
                        return self.queue_2.pop(0)
        else:
            return None
    def top(self) -> int:
        if self.empty():
            return None
        return self.topElem

    def empty(self) -> bool:
        if len(self.queue_1)==0 and len(self.queue_2)==0:
            return True
        else:
            return False
# Your MyStack object will be instantiated and called as such:
x=2
obj = MyStack()
obj.push(x)
param_3 = obj.top()
param_2 = obj.pop()
print(param_2)
print(param_3)
param_4 = obj.empty()
print(param_4)